﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;

[LuaCallCSharp]
public class LuaTool : MonoBehaviour
{
    public static LuaTool Instance;
    LuaEnv env;
    public bool isResetEnv = false;
    public LuaEnv LuaEnv {

        get
        {
            if (env == null || isResetEnv == true)
            {
                ResetLuaEnv();
            }

            return env;
        }
    }


    public void Awake()
    {
        Instance = this;
        LuaEnv.DoString("require 'init'");
    }

    private void ResetLuaEnv()
    {
        env = new LuaEnv();
        env.RestartGc();
        isResetEnv = false;

        env.AddLoader(LuaLoaderTool.LoadFile);
    }


}
